<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/8/14
  Time: 9:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="<c:url value='/js/jquery-1.8.2.js'/>"></script>
</head>
<script>
    function paging(obj){
        var yema="";
        if(obj=='go'){
            yema=document.getElementById("tz").value;
        }else{
            yema=obj;
        }
        document.getElementsByName("yema")[0].value=yema;
        document.forms[0].submit();
    }
</script>
<body>
    <center>
        <form action="<c:url value='/getUserList.do'/>" method="post">
            <input type="hidden" name="yema" value="${yema}">
        </form>
        <table border="1" rules="all">
            <tr align="center" bgcolor="aqua">
                <td>用户编号</td>
                <td>用户名称</td>
                <td>用户年龄</td>
                <td>用户操作</td>
            </tr>
            <c:forEach var="u" items="${list}" varStatus="a">
                <tr align="center" bgcolor="${a.index%2==0?'pink':''}">
                    <td>${u.id}</td>
                    <td>${u.username}</td>
                    <td>${u.age}</td>
                    <td>
                        <a href="<c:url value='/deleteUserById.do?id=${u.id}'/>"><button>删除用户</button></a>
                        <a href="<c:url value='/getUserOrderList.do?id=${u.id}'/>"><button>查看订单</button></a>
                        <a href="<c:url value='/getProList.do?id=${u.id}'/>"><button>购买商品</button></a>
                    </td>
                </tr>
            </c:forEach>
            <tr>
            <tr>
                <td colspan="20">
                    当前${page.currentPage}/${page.pageCount}页 &nbsp;共${page.count}条记录&nbsp;
                    <button onclick="paging(1)">首页</button>
                    <button onclick="paging('${page.previousPage}')">上一页</button>
                    <button onclick="paging('${page.nextPage}')">下一页</button>
                    <button onclick="paging('${page.pageCount}')">尾页</button>
                    跳转到<input type="text" id="tz" size="1" value="${page.currentPage}"><button onclick="paging('go')">go</button>
                </td>
            </tr>
            </tr>
        </table>

    </center>
</body>
<script>
    /*function sc(obj) {
        if(confirm("您确定要删除该用户吗")){
            location.href="<c:url value='/deleteUser.do?bid='/>"+obj;
        }
    }*/
</script>
</html>
